home *** CD-ROM | disk | FTP | other *** search
- /*
- * strcmp.c --
- *
- * Source code for the "strcmp" library routine.
- *
- * Copyright 1988 Regents of the University of California
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /sprite/src/lib/c/string/RCS/strcmp.c,v 1.3 92/03/27 13:29:58 rab Exp $ SPRITE (Berkeley)";
- #endif /* not lint */
-
- #include <string.h>
-
- /*
- *----------------------------------------------------------------------
- *
- * strcmp --
- *
- * Compare two strings lexicographically.
- *
- * Results:
- * The return value is 0 if the strings are identical, 1
- * if the first string is greater than the second, and
- * -1 if the first string is less than the second. If one
- * string is a prefix of the other then it is considered
- * to be less (the terminating zero byte participates in the
- * comparison).
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
- int
- strcmp(s1, s2)
- register char *s1, *s2; /* Strings to compare. */
- {
- int c1, c2;
-
- while (1) {
- c1 = *s1++;
- c2 = *s2++;
- if (c1 != c2) {
- return c1 - c2;
- }
- if (c1 == 0) {
- return 0;
- }
- }
- }
-